#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

class Solution {
public:
    vector<int> getMaximumXor(vector<int>& nums, int maximumBit) {
        //第一个要自己找
        int maximum = pow(2,maximumBit);
        int temp = 0;
        for(int i = 0;i<nums.size();++i){
            temp ^= nums[i];
            
        }
        int maxvalue = INT16_MIN;
        int index =0;
        for(int i = 0;i<maximum;++i){
            if((i^temp)>maxvalue){
                index = i;
            }
            maxvalue = max(maxvalue,i^temp);
        }

        vector<int> result;
        result.push_back(index);
        for(int i = nums.size()-1;i>0;--i){
            index = index^nums[i];
            result.push_back(index);
        }
        return result;
    }
};

int main(){
    Solution S;
    vector<int> nums = {0,1,2,2,5,7};
    vector<int>result = S.getMaximumXor(nums,3);
    return 0;
}